package userService

import (
	"chart.zozoo.net/app/models"
	"chart.zozoo.net/core/mysql"
	"errors"
	"gorm.io/gorm"
)

// InfoByKeywords 根据关键词搜索用户
func InfoByKeywords(keywords string) (u *models.Users, err error) {
	row := mysql.MysqlClient.
		Select("id", "uuid", "username", "headimgurl", "nickname", "city", "profile").
		Where("username = ? or uuid = ?", keywords, keywords).
		Find(&u)
	if row.Error != nil && !errors.Is(row.Error, gorm.ErrRecordNotFound) {
		return nil, err
	}

	return u, nil
}
